-- Leviathan (c) v.v.balashoff
local Class = require('leviathan/Class')

local FPSSystem = Class:derive('UIFPSSystem')

function FPSSystem:new(domain)
    self.name = 'FPSSystem'
    self.domain = domain
end

function FPSSystem:update(dt)
    local r = self.domain.components['FPS']
    for _, c in pairs(r) do
        if c.enabled then
            local fpsNow = love.timer.getFPS()
            local fpsOld = c.target.text
            if not (fpsOld == fpsNow) then
                c.target.text = fpsNow
                c.entity.domain.changed = true
            end
        end
    end
end

return FPSSystem
